
package net.lab0.fractal.concurrent;


/**
 * 
 * @author 116
 * 
 *         Worker interface for Runnables intended to be used with QueuedRunnableGroup
 * 
 * @see QueueableRunnableGroup
 * 
 * @param <In>
 *            Input type
 * @param <Out>
 *            Output type
 */
public interface QueueableRunnableInterface<In, Out>
extends Runnable
{
    /**
     * 
     * @return The group this QueableRunnabl belongs to
     */
    public QueueableRunnableGroup<In, Out> getQueueableRunnableGroup();
    
    /**
     * asks for this worker to stop
     */
    public void stopWork();
    
    /**
     * 
     * A stopped worker must reach the return point of his <code>void run()</code> method
     * 
     * @return <code>true</code> if this worker is stopped
     */
    public boolean isStopped();
    
    /**
     * 
     * asks for this worker to finish the tasks in the input queue and exit its <code>void run()</code> method after that
     * 
     */
    public void finishWork();
    
    /**
     * 
     * A finishing worker must reach the return point of his <code>void run()</code> method after finishing the remain work in queue
     * 
     */
    public boolean isFinishing();
}
